package com.fawvwebanma.dto;

import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author jieye.ren
 * @date 2021/3/12
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> implements Serializable {
    private boolean isSuccess;
    private T data;
    private String errCode;
    private String errMsg;

    public static <T> Result<T> success() {
        return new Result<T>(true, null, "", "");
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(true, data, "", "");
    }

    public static <T> Result<T> error(String errCode, String errMsg) {
        return new Result<T>(false, null, errCode, errMsg);
    }
}
